<?php
/* SVN FILE: $Id: grading_option.php 11 2009-09-12 23:39:35Z kenreily@gmail.com $ */
/**
 * Short description for file.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * Recenseo: Online submission and reviewing for education
 * Copyright 2008-2009, Ken Reily
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * $Date: 2009-09-12 23:39:35 +0000 (Sat, 12 Sep 2009) $
 * $Revision: 11 $
 * $Author: kenreily@gmail.com $
 * $HeadURL: http://recenseo.googlecode.com/svn/trunk/app/models/grading_option.php $
 */
class GradingOption extends AppModel {
  var $name = 'GradingOption';
  var $hasMany = 'Submission';
  var $hasAndBelongsToMany = 'Assignment';
  
  function getListForAssignment($assignment_id)
  {
    $options = $this->query("SELECT id,name " .
                              "FROM grading_options AS go " .
                              "JOIN assignments_grading_options AS ago ON ago.grading_option_id = go.id " .
                             "WHERE ago.assignment_id = {$assignment_id}");

    $ret_arr = array();
    
    foreach ($options as $option)
    {
      $key = $option['go']['id'];
      $value = $option['go']['name'];
      $ret_arr[$key] = $value;
    }
    
    return $ret_arr;    
  }
}
?>